<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>找回密码-{{$SEO['title']}}</title>
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <!--公用css引用-->
    @include('front.common.style')
    <!--END/公用css引用-->
    <link rel="stylesheet" href="../dist/css/login.css">
</head>
<body>

<!--头部-->
<div class="login-head inbox">
    <div class="logo-wrap">
        <a href="/"><img class="logo fn-fl" src="../images/logo.jpg" alt="阿福易购"></a>
        <span class="welcome fn-fl">找回密码</span>
    </div>
</div>
<!--END/头部-->

<div class="inbox getBack-pwd">
    <div class="getPwd-h">
        <span class="h-txt">找回密码</span>
    </div>

    <div class="getPwd-b">
        <div class="b-inner">
            <!--第一步-->

            <?php
            if(Session::has('step')) {
            $step = Session::get('step');
            }

            ?>

            @if($step=="step_1")
            <div class="step-by-step">
                <div class="gray-line"></div>
                <div class="success-line" style="width: 33%;"></div>
                <div class="before-line" style="width: 0%;"></div>
                <ul class="step-list ui-cols-3">
                    <li class="step col step-cur">
                        <i class="icon icon-step">1</i>
                        <div class="txt">验证身份</div>
                    </li>
                    <li class="step col">
                        <i class="icon icon-step">2</i>
                        <div class="txt">修改登录密码</div>
                    </li>
                    <li class="step col">
                        <i class="icon icon-step">3</i>
                        <div class="txt">完成</div>
                    </li>
                </ul>
            </div>

            {{--<form action="#" class="js-form bl-form bl-formhor form-L">--}}
            {!! Form::model($user,['route'=>'my.forgetPwd.find_pwd','class'=>'js-form bl-form bl-formhor form-L'])  !!}
            {!! Form::hidden('_method', 'POST') !!}
                <div class="bl-form-group">
                    <label><em class="text-color-6">*</em>已绑定手机号：</label>
                    <div class="controls">
                    {!! Form::text('phone',old('phone'),array('id'=>'phone', 'class'=>'fn-tinput fn-tinput-small elementJs', 'placeholder'=>'请填写手机号','required'=>'required'))!!}
                        {{--<input class="fn-tinput fn-tinput-long elementJs" required="" id="phone" name="phone" type="text" value="" placeholder="请填写手机号">--}}
                    <div id="phone-error" class="error"></div>
                    </div>
                </div>

                <div class="bl-form-group">
                    <label><em class="text-color-6">*</em>短信验证码：</label>
                    <div class="controls">
                    {!! Form::text('MSGCode',old('MSGCode'),array('id'=>'MSGCode', 'class'=>'fn-tinput fn-tinput-small elementJs', 'placeholder'=>'请填写短信验证码','required'=>'required'))!!}

                        <a id="btnSendCode" class="fn-btn diy-error js-getCode" style="width: 100px;">获取短信验证码</a>
                    </div>
                </div>

                <div class="bl-form-group">
                    <label><em class="text-color-6">*</em>验证码：</label>
                    <div class="controls">

                        <input class="fn-tinput fn-tinput-small elementJs" required="" id="Code" name="Code" type="text" value="" placeholder="验证码">
                        <a class="chk-code" href="javascript:;"><img style="width:77px;height:36px;" src="{{ URL('captcha/0.1') }}" id="chkCode" alt=""></a>
                        <span>看不清？<a class="text-color-8" href="javascript:;"onclick="javascript:re_captcha();">换一张</a></span>
                        @if(Session::has('message'))
                            <p id="Code-error" class="error"> {{Session::get('message')}}</p>
                        @endif
                    </div>
                </div>



                <div class="bl-form-group bl-form-btns">
                    <label class="fn-vhide">提交：</label>
                    <div class="controls">
                        <button class="fn-btn btn-primary fn-mr8 btn-save" type="submit">确定</button>
                    </div>
                </div>
            {!! Form::close()  !!}
            {{--</form>--}}
            @endif

            <!--END/第一步-->



            <!--第二步-->
            @if($step=='step_2')
            <div class="step-by-step">
                <div class="gray-line"></div>
                <div class="success-line" style="width: 66%;"></div>
                <div class="before-line" style="width: 33%;"></div>
                <ul class="step-list ui-cols-3">
                    <li class="step col step-before">
                        <i class="icon icon-step">1</i>
                        <div class="txt">验证身份</div>
                    </li>
                    <li class="step col step-cur">
                        <i class="icon icon-step">2</i>
                        <div class="txt">修改登录密码</div>
                    </li>
                    <li class="step col">
                        <i class="icon icon-step">3</i>
                        <div class="txt">完成</div>
                    </li>
                </ul>
            </div>
            {!! Form::model($user,['route'=>'my.forgetPwd.store','class'=>'js-form js-placeholder bl-form bl-formhor form-L'])  !!}

                <div class="bl-form-group">
                    <label><em class="text-color-6">*</em>新密码：</label>
                    <div class="controls">
                        <input id="newPwd" class="fn-tinput elementJs" required="" name="newPwd" type="password" value="" placeholder="请填写新密码" autocomplete="off">
                        @if($errors->has('newPwd'))
                        <div class="error">{{$errors->first('newPwd')}}</div>
                        @else
                        <div class="form-help">由字母加数字或符号，至少两种以上字符组成的6-20位字符，区分大小写</div>
                        @endif
                    </div>
                </div>

                <div class="bl-form-group">
                    <label><em class="text-color-6">*</em>再次输入新密码：</label>
                    <div class="controls">
                        <input class="fn-tinput elementJs" required="" name="password_confirmation" type="password" value="" placeholder="请再次填写新密码" autocomplete="off">
                        @if($errors->has('password_confirmation'))<div class="error">{{$errors->first('password_confirmation')}}</div>@endif
                        @if(Session::has('message'))
                            <p id="password_confirmation-error" class="error"> {{Session::get('message')}}</p>
                        @endif
                    </div>
                </div>

                {{--<div class="bl-form-group">--}}
                    {{--<label><em class="text-color-6">*</em>验证码：</label>--}}
                    {{--<div class="controls">--}}
                        {{--<input class="fn-tinput fn-tinput-small elementJs" required="" name="Code" type="text" value="" placeholder="验证码">--}}
                        {{--<a class="chk-code" href="javascript:;"><img style="width:77px;height:36px;" src="../images/login/chk-code.jpg" alt=""></a>--}}
                        {{--<span>看不清？<a class="text-color-8" href="javascript:;">换一张</a></span>--}}
                    {{--</div>--}}
                {{--</div>--}}

                {{--@if($errors->has())--}}
                {{--<div class="bl-form-group">--}}
                    {{--<label class="fn-vhide fn-mr6">错误信息：</label>--}}
                    {{--<div class="error"> {{$errors->first()}}</div>--}}
                {{--</div>--}}
                {{--@endif--}}

                <div class="bl-form-group bl-form-btns">
                    <label class="fn-vhide">提交：</label>
                    <div class="controls">
                        <button class="fn-btn btn-primary fn-mr8 btn-save" type="submit">确定</button>
                    </div>
                </div>

            {!! Form::close()  !!}
            @endif
            <!--END/第二步-->

            <!--第三步-->
            @if($step=='step_3')
            <div class="step-by-step">
                <div class="gray-line"></div>
                <div class="success-line" style="width: 100%;"></div>
                <div class="before-line" style="width: 66%;"></div>
                <ul class="step-list ui-cols-3">
                    <li class="step col step-before">
                        <i class="icon icon-step">1</i>
                        <div class="txt">验证身份</div>
                    </li>
                    <li class="step col step-before">
                        <i class="icon icon-step">2</i>
                        <div class="txt">修改登录密码</div>
                    </li>
                    <li class="step col step-cur">
                        <i class="icon icon-step">3</i>
                        <div class="txt">完成</div>
                    </li>
                </ul>
            </div>
            <div class="success-tip">
                <p>您的登录密码已修改！ <span class="js-num">3</span>秒后重新登录。 <a href="/user/login" class="text-color-9 link">立即登录</a></p>
            </div>
            @endif
            <!--END/第三步-->

        </div>
    </div>



</div>

<!--底部-->
<div class="f-aboutUs">
    <div class="inbox fn-tc">
        <a href="#">关于阿福易购</a>
        <a href="#">公司简介</a>
        <a href="#">联系我们</a>
        <a href="#">招聘信息</a>
        <a href="#">用户协议</a>
        <br>
        <p>
            <span>增值电信经营许可证：豫B2-29877666-4</span><a class="fn-ml10 link" target="_blank" href="http://www.miitbeian.gov.cn/">ICP备案号：豫ICP16000288号-1</a> Copyright ©<a class="link" href="/">WWW.AFYIGOU.COM</a> 2015
        </p>
    </div>
</div>
<!--END/底部-->

<!--公用js引用-->
@include('front.common.script')
<!--END/公用js引用-->
<script src="../dist/js/jquery.validation.js"></script>
<script>

  function re_captcha() {
        var $url = "{{ URL('captcha') }}" + "/" + Math.random();
        $('#chkCode').attr('src',$url);
  }

var codeBtn=$('#btnSendCode');
codeBtn.click(function(){
if(codeBtn.hasClass('disabled')) return false;
    var that=$(this),sNum=60000,countDown;
    var phone = $('#phone'),phoneNum=phone.val();


    if(!phone.valid()){
        phone.focus();
        return false;
    }

    countDown=tools.buttonCountdown(that,sNum,'s','后重发',phoneNum);
    $.ajax({
        url:"{{ URL('my/sms') }}"+ "?t=" + Math.random(),
        data:{phone:phoneNum},
        type:'post',
        dataType:'json',
        success:function(res){
            if(res.status==0){
                countDown.clearTime();
                codeBtn.removeClass('disabled').prop('disabled',false);
                var errorItem=phone.siblings('.error');
                if(errorItem.length){
                    errorItem.text(res.message).show();
                }else{
                    phone.after('<label class="error">'+res.message+'</label>');
                }
            }

        },
        error:function(e){
            countDown.clearTime();
            that.removeClass('disabled');
            phone.next('.error').show().text(e.responseJSON.phone[0]).end().focus();
        }
    })
});

//倒计时
var numItem=$('.js-num');
if(numItem.length){
    var num=3;
    setTimeout(function(){
        num--;
        numItem.text(num);
        if(num<1){
            window.location.href='/user/login';
        }else{
            setTimeout(arguments.callee(),1000);
        }
    },1000);
}


$('.js-form').validate({
    errorElement:'p',
    rules: {
        phone:{
            mobile:true
        },
        newPwd:{
            pwd:true
        },
        password_confirmation:{
            equalTo:'#newPwd'
        }
    },
    messages: {
        phone:{
            required:'请填写您的手机号'
        },
         MSGCode:{
             required:'请填写短信验证码'
         },
         Code:{
             required:'请填写验证码'
         },
         newPwd:{
             required:'请填写您的密码',
             pwd:'密码6-20位字符，建议由字母、数字、符号两种以上组合'
         },
         password_confirmation:{
            required:'请确认您的密码',
            equalTo:'两次输入密码不一致'
         }
    },
    errorPlacement: function(error, element) {
      var parentItem=element.parent(".controls"),
          errorItem=parentItem.find('.error');
           if(errorItem.length==2){
              errorItem.eq(1).remove();
           }
       error.appendTo(parentItem);
    }
});

</script>
</body>
</html>
